﻿using Md.Api.DDD;
using Md.Api.Model.Manage.SysUser.Request;
using Md.Dapper.Repositories.Md;

namespace Md.Api.Service.Manage.SysUser;
/// <summary>
/// 重置系统用户密码服务
/// </summary>
public class ResetSysUserPwdService : ApiBase<RequestResetSysUserPwdModel>
{
    /// <summary>
    /// 系统用户仓储
    /// </summary>
    public SysUserRep sysUserRep { get; set; }
    /// <summary>
    /// 执行
    /// </summary>
    protected override void ExecuteMethod()
    {
        var pwd = EncrptyHelp.MD5Pwd(Parameter.Password);

        var res = sysUserRep.UpdateSysUserPwdByUserId(Parameter.UserId, pwd);

        if (res > 0)
        {
            Result.Data = sysUserRep.GetSysUserByUserId(Parameter.UserId);
        }
    }
}
